<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
    <script src="../node_modules/vue/dist/vue.global.js"></script>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="item in heroArr" :key="item.id">
                <p>
                    <input type="checkbox">
                    {{item.name}}
                </p>
            </li>

            <button @click="addHero">添加英雄</button>

        </ul>
    </div>
</body>

</html>
<script>
    const { createApp } = Vue;
    const vm = createApp({
        data() {
            return {
                message1: 'Hello',
                heroArr: [
                    {
                        id: 1,
                        name: '盖伦'
                    },
                    {
                        id: 2,
                        name: '诺克'
                    },
                    {
                        id: 3,
                        name: '光辉女郎'
                    }
                ]
            }
        },
        methods: {
            addHero() {
                this.heroArr.unshift({
                    id: this.heroArr[0].id - 1,
                    name: '德玛西亚皇子'
                })
            }
        }
    }).mount('#app') 
</script>